package com.meisiabc.app.config;

import com.meisiabc.support.email.EmailClient;
import com.meisiabc.support.email.MockEmailClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
public class EmailConfig {
    @Autowired
    JavaMailSender mailSender;

    @Bean
//    @Profile("prod")
    public EmailClient emailClient() {
        return new EmailClient(mailSender);
    }

    @Bean
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
        ThreadPoolTaskExecutor bean = new ThreadPoolTaskExecutor();
        bean.setCorePoolSize(5);
        bean.setMaxPoolSize(10);
        return bean;
    }
//
//    @Bean
//    @Profile("!prod")
//    public EmailClient mockEmailClient() {
//        return new MockEmailClient();
//    }
}
